package com.business.file.rabbitMq;

import com.alibaba.fastjson.JSONObject;
import com.business.common.enums.RabbitMqConstant;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.UUID;


/**
 * 发送消息工具类
 *
 * @author chenjiehong
 * @date 2019-07-20
 */

@Component
public class RabbitMqSender {

    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * 压缩图片
     */
    public void resizedImage(String path) {
        CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
        String routKey = RabbitMqConstant.RESIZED_IMAGE;
        JSONObject params = new JSONObject();
        params.put("filePath", path);//路径
        rabbitTemplate.convertAndSend(RabbitMqConstant.EXCHANGE_DIRECT, routKey, params, correlationData);
    }

}
